//
//  SHHTTPTOOL.m
//  youjian03
//
//  Created by 常琼 on 14/10/10.
//  Copyright (c) 2014年 com.shouhuobao. All rights reserved.
//

#import "SHHTTPTOOL.h"
#import "HMHttpTool.h"
#import "SHUtilitiesTool.h"


@implementation SHHTTPTOOL

+(void)PostWithDic:(NSDictionary *)msg andAction:(NSString *)action success:(void (^)(id responseObj))success failure:(void (^)(NSError *error))failure
{

    NSString *json = [NSString stringWithFormat: @"{\"action\":\"%@\",\"msg\":%@}",action,msg];
    NSDictionary *param = @{@"json":json};
    [HMHttpTool post:SHAPIURL_DATA_B params:param success:^(id responseObj) {
        if (success) {
            success(responseObj);
        }
        
    } failure:^(NSError *error) {

        HMLog(@"jeolo -error is :%@",error);
    }];
    
    
    
    
    
}

+(void)PostWithString:(NSDictionary *)msg andAction:(NSString *)action success:(void (^)(id responseObj))success failure:(void (^)(NSError *error))failure
{
    
    
    
    NSDictionary * dictest = @{@"action":action,@"msg":msg};
    NSError *parseError = nil;
    NSString *jsondic = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:dictest options:NSJSONWritingPrettyPrinted error:&parseError] encoding:NSUTF8StringEncoding];
    
    NSDictionary *param = @{@"json":jsondic};
    [HMHttpTool post:SHAPIURL_DATA_B params:param success:^(id responseObj) {
        if (success) {
            success(responseObj);
        }
        
    } failure:^(NSError *error) {
        
        HMLog(@"error is :%@",error);
    }];
    
    
    
    
    
}

//新建订单
+(void)PostOrderWithDic:(NSDictionary *)msg andAction:(NSString *)action success:(void (^)(id responseObj))success failure:(void (^)(NSError *error))failure
{
    

    NSDictionary * dic2 = @{@"action":action,@"msg":msg};
    NSString * json = [SHUtilitiesTool dictionaryToJson:dic2];
    
    NSDictionary *param = @{@"json":json};
    [HMHttpTool postVoiceOrder:SHAPIURL_DATA_B params:param success:^(id responseObj) {
        if (success) {
            success(responseObj);
        }
        
    } failure:^(NSError *error) {
        
        HMLog(@"error is :%@",error);
    }];
    
    
    
    
    
}


@end
